import Vue from "vue"
let prototype = Vue.prototype;

export default {
    /**
     * 安装分类
     */
    getInstallCate() {
        return new Promise((resolve, reject) => {
            prototype.$request({
                api: "service.cate",
            }).then((response) => {
                if (response.code == 1) {
                    let list = [];
                    response.data.forEach((item) => {
                        let child = [];
                        item.child.forEach((v) => {
                            child.push({
                                id: v.id,
                                name: v.name,
                                cover: v.more,
                                page: "",
                            });
                        });
                        list.push({
                            id: item.id,
                            name: item.name,
                            cover: item.more,
                            child: child,
                            page: "",
                        });
                    });
                    return resolve(list);
                }
                return reject(response.msg);
            });
        });
    },
    /**
     * 获取车辆类型
     */
    getCarType() {
        return new Promise((resolve, reject) => {
            prototype.$request({
                api: "service.carType",
            }).then(response => {
                if (response.code == 1) {
                    let list = [];
                    response.data.forEach(item => {
                        list.push({
                            id: item.id,
                            name: item.title
                        });
                    });
                    return resolve(list);
                }
                return reject(response.msg);
            });
        });
    },
}
